<?php

/**
 * This is the model class for table "adm_company".
 *
 * The followings are the available columns in table 'adm_company':
 * @property string $id_adm_company
 * @property string $name
 * @property string $address
 * @property string $phone
 * @property string $fax
 * @property string $gm
 * @property string $director
 * @property string $pur_manager
 * @property string $npwp
 * @property string $skep_kawasan_berikat
 * @property string $wh_manager
 * @property string $city
 *
 * The followings are the available model relations:
 * @property AdmUser[] $admUsers
 */
class AdmCompany extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AdmCompany the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'adm_company';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, address, phone, fax, gm, director, pur_manager, npwp, skep_kawasan_berikat, wh_manager, city', 'length', 'max'=>50),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_adm_company, name, address, phone, fax, gm, director, pur_manager, npwp, skep_kawasan_berikat, wh_manager, city', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'admUsers' => array(self::HAS_MANY, 'AdmUser', 'id_adm_company'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_adm_company' => 'Id Adm Company',
			'name' => 'Name',
			'address' => 'Address',
			'phone' => 'Phone',
			'fax' => 'Fax',
			'gm' => 'Gm',
			'director' => 'Director',
			'pur_manager' => 'Pur Manager',
			'npwp' => 'Npwp',
			'skep_kawasan_berikat' => 'Skep Kawasan Berikat',
			'wh_manager' => 'Wh Manager',
			'city' => 'City',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_adm_company',$this->id_adm_company,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('fax',$this->fax,true);
		$criteria->compare('gm',$this->gm,true);
		$criteria->compare('director',$this->director,true);
		$criteria->compare('pur_manager',$this->pur_manager,true);
		$criteria->compare('npwp',$this->npwp,true);
		$criteria->compare('skep_kawasan_berikat',$this->skep_kawasan_berikat,true);
		$criteria->compare('wh_manager',$this->wh_manager,true);
		$criteria->compare('city',$this->city,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}